package com.myhome.money.ssm.springmvc.controller;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.myhome.money.ssm.springmvc.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: 许路路
 * @Date: 2019/1/7
 */
@RequestMapping("nacos")
@Controller
public class NacosConfigController {

    @Autowired
    private DemoService demoService;

    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
    private boolean useLocalCache;

    @RequestMapping(value = "/get")
    @ResponseBody
    public boolean get() {
        return useLocalCache;
    }

    @RequestMapping("hello")
    @ResponseBody
    public String hello() {
        String res = demoService.hello("xululu");
        return res;
    }

    public boolean isUseLocalCache() {
        return useLocalCache;
    }

    public void setUseLocalCache(boolean useLocalCache) {
        this.useLocalCache = useLocalCache;
    }
}
